<?php

namespace App\Console;

use App\Services\Order\OrderServices;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Log;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();
        // 执行定时任务,在每天的3:00自动确认收货
        // crontab -u www -e
        $schedule->call(function (){
            OrderServices::getInstance()->autoConfirm();
        })->dailyAt('3:00')->runInBackground()->name('auto_confirm')->onOneServer();

        // 每分钟执行一次
        $schedule->call(function (){
            Log::info('test schedule');
        })->everyMinute()->runInBackground()->name('log')->onOneServer();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
